package com.sanxia.equipment.service.impl;

import java.util.Date;
import java.util.List;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.sanxia.equipment.vo.SupplierVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.sanxia.equipment.mapper.SupplierMapper;
import com.sanxia.equipment.domain.Supplier;
import com.sanxia.equipment.service.ISupplierService;

/**
 * 供应商列表Service业务层处理
 *
 * @author 贤哥编程
 * @date 2023-04-25
 */
@Service
public class SupplierServiceImpl implements ISupplierService
{
    @Autowired
    private SupplierMapper supplierMapper;

    /**
     * 查询供应商列表
     *
     * @param supplierId 供应商列表主键
     * @return 供应商列表
     */
    @Override
    public Supplier selectSupplierBySupplierId(Long supplierId)
    {
        return supplierMapper.selectSupplierBySupplierId(supplierId);
    }

    /**
     * 查询供应商列表列表
     *
     * @param supplier 供应商列表
     * @return 供应商列表
     */
    @Override
    public List<Supplier> selectSupplierList(Supplier supplier)
    {
        return supplierMapper.selectSupplierList(supplier);
    }

    /**
     * 新增供应商列表
     *
     * @param supplier 供应商列表
     * @return 结果
     */
    @Override
    public int insertSupplier(Supplier supplier)
    {
        supplier.setCreateTime(DateUtils.getNowDate());
        return supplierMapper.insertSupplier(supplier);
    }

    /**
     * 修改供应商列表
     *
     * @param supplier 供应商列表
     * @return 结果
     */
    @Override
    public int updateSupplier(Supplier supplier)
    {
        supplier.setUpdateTime(DateUtils.getNowDate());
        return supplierMapper.updateSupplier(supplier);
    }

    /**
     * 批量删除供应商列表
     *
     * @param supplierIds 需要删除的供应商列表主键
     * @return 结果
     */
    @Override
    public int deleteSupplierBySupplierIds(Long[] supplierIds)
    {
        return supplierMapper.deleteSupplierBySupplierIds(supplierIds);
    }

    /**
     * 删除供应商列表信息
     *
     * @param supplierId 供应商列表主键
     * @return 结果
     */
    @Override
    public int deleteSupplierBySupplierId(Long supplierId)
    {
        return supplierMapper.deleteSupplierBySupplierId(supplierId);
    }

    @Override
    public Integer audit(SupplierVo supplierVo) {
        Supplier supplier = new Supplier();
        supplier.setSupplierId(supplierVo.getSupplierId());
        supplier.setAuditStatus(supplierVo.getAuditStatus());
        supplier.setAuditOpinion(supplierVo.getAuditOpinion());
        supplier.setAuditTime(new Date());
        supplier.setAuditPerson(SecurityUtils.getUsername());
        int i = supplierMapper.updateSupplier(supplier);
        return i;
    }

    @Override
    public int approverSupplier(SupplierVo supplierVo) {
        Supplier supplier = new Supplier();
        supplier.setSupplierId(supplierVo.getSupplierId());
        supplier.setAuditStatus(supplierVo.getAuditStatus());
        supplier.setApproverOpinion(supplierVo.getApproverOpinion());
        supplier.setApproverTime(new Date());
        supplier.setApproverPerson(SecurityUtils.getUsername());
        int i = supplierMapper.updateSupplier(supplier);
        return i;
    }

    @Override
    public List<Supplier> selectSupplierLists() {
        return supplierMapper.selectSupplierLists();
    }


}
